package map;

import java.util.*;

//统计line中每个字符出现的次数并输出
public class Test {
    public static void main(String[] args) {
        String line = "helloworld!!thinking in java!!!我喜欢java!我要成为java大神!";
        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < line.length(); i++) {
            char c = line.charAt(i);
            if (map.containsKey(c)) {
                int num = map.get(c);
                num++;
                map.put(c, num);
            } else {
                map.put(c, 1);
            }
        }
        System.out.println(map);
    }
}
